<template>
  <section class="w-[210px] h-6">
    <el-input v-model="searchInput" @input="onInput"></el-input>
  </section>
</template>
<script lang="ts" setup>
import type { UserListType } from '@renderer/api/user/type'

const props = defineProps<{
  totalList: UserListType[]
}>()
const filteredList = defineModel<UserListType[]>('filteredList', { required: true })
const searchInput = defineModel<string>('searchInput', { required: true })
function onInput(v: string) {
  v = v.toLocaleLowerCase()
  filteredList.value = props.totalList.filter(
    (user) =>
      v &&
      (user.name.toLocaleLowerCase().includes(v) || user.nickname.toLocaleLowerCase().includes(v))
  )
  console.log(filteredList.value, 'filteredList.value')
}
</script>
<style lang="scss" scoped></style>
